package io.renren.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.entity.XlsLogThirdpayEntity;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.dao.XlsLogThirdpayDao;
import io.renren.dto.XlsLogThirdpayDTO;
import io.renren.service.XlsLogThirdpayService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 第三方支付记录表
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2020-04-12
 */
@Service
public class XlsLogThirdpayServiceImpl extends CrudServiceImpl<XlsLogThirdpayDao, XlsLogThirdpayEntity, XlsLogThirdpayDTO> implements XlsLogThirdpayService {

    @Autowired
    private XlsLogThirdpayDao xlsLogThirdpayDao;

    @Override
    public QueryWrapper<XlsLogThirdpayEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<XlsLogThirdpayEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public List<XlsLogThirdpayEntity> selectLogThirdpayList(XlsLogThirdpayEntity logThirdpay) {
        return xlsLogThirdpayDao.selectLogThirdpayList(logThirdpay);
    }

    @Override
    public XlsLogThirdpayEntity initLogThirdpay(Long userId, String businessType, int payType, String ino, BigDecimal payMoney,
                                                String outTradeNo, String request, int payStatus, String remark){
        XlsLogThirdpayEntity logThirdpay=new XlsLogThirdpayEntity();
        logThirdpay.setUserId(userId);
        logThirdpay.setBusinessType(businessType);
        logThirdpay.setPayType(payType);
        logThirdpay.setIno(ino);
        logThirdpay.setPayMoney(payMoney);
        logThirdpay.setOutTradeNo(outTradeNo);
        logThirdpay.setRequest(request);
        logThirdpay.setPayStatus(payStatus);
        logThirdpay.setRemark(remark);
        logThirdpay.setCreateTime(new Date());
        logThirdpay.setDataFlag(1);
        return logThirdpay;
    }

    @Override
    public int insertThirdpay(XlsLogThirdpayEntity newLogThirdpay) {
        return xlsLogThirdpayDao.insertThirdpay(newLogThirdpay);
    }
}